package com.zhuss.order.processor;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;

import com.zhuss.bean.bo.order.order.UpdatePrefundBo;
import com.zhuss.common.AbstractProcessor;
import com.zhuss.common.Processor;
import com.zhuss.exception.DzcxException;
import com.zhuss.order.db.dao.ext.PrefundDao;
import com.zhuss.order.db.entity.Prefund;

/**
 * @description: 退款返回记录修改
 * @author: zhushanshuo
 * @create: Fri Jan 15 22:17:59 CST 2021
 **/
@Component("prefundUpdate")
public class PrefundUpdate extends AbstractProcessor<Object, UpdatePrefundBo> implements Processor<Object, UpdatePrefundBo> {

    @Autowired
    private PrefundDao prefundDao;
    
    @Autowired
	@Qualifier("prefundRead")
	private PrefundRead prefundRead;
    
    /**
     * 校验
     */
    @Override
    public void check(UpdatePrefundBo bo) throws DzcxException {
    	// TODO 修改 退款返回记录 校验， 请补充
    	
    	Long prefundId = bo.getPrefundId();
    	if (prefundId == null || prefundId <= 0l) {
//    		throw new DzcxException(ExceptionCode.退款返回记录ID为空);
    	}
    	
    }
    
    /**
     * 操作方法
     */
    @Override
    public Object process(UpdatePrefundBo param) {
    	Prefund record = new Prefund();
    	record.setPrefundId(param.getPrefundId());
    	record.setOrderId(param.getOrderId());
    	record.setOrderRefundId(param.getOrderRefundId());
    	record.setAppId(param.getAppId());
    	record.setMchId(param.getMchId());
    	record.setTradeType(param.getTradeType());
    	record.setNonceStr(param.getNonceStr());
    	record.setTransactionId(param.getTransactionId());
    	record.setApplyTotalFee(param.getApplyTotalFee());
    	record.setApplyRefundFee(param.getApplyRefundFee());
    	record.setTotalFee(param.getTotalFee());
    	record.setRefundFee(param.getRefundFee());
    	record.setSettlementTotalFee(param.getSettlementTotalFee());
    	record.setSettlementRefundFee(param.getSettlementRefundFee());
    	record.setCashFee(param.getCashFee());
    	record.setCashRefundFee(param.getCashRefundFee());
    	record.setSign(param.getSign());
    	record.setReturnMsg(param.getReturnMsg());
    	record.setResultCode(param.getResultCode());
    	record.setReturnCode(param.getReturnCode());
    	record.setWxRefundId(param.getWxRefundId());
    	record.setStatus(param.getStatus());

    	
    	record.setModifierId(param.getConcurrentUserId());
    	record.setModifier(param.getConcurrentUserName());
    	record.setModifyTime(new Date());
    	prefundDao.updateByPrimaryKeySelective(record);
        return null;
    }
    
    /**
     * 操作日志
     */
	@Override
	public Object log(UpdatePrefundBo param) throws DzcxException {
    	return null;
	}
}
